﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Reflection;

namespace JQuery
{
    public static partial class Extensions
    {
        public static string ToItemTemplate<T>(this T @object, string name, bool isTemplate)
            where T: class
        {
            PropertyInfo oProperty = typeof(T).GetProperty(name);

            return isTemplate ? String.Format("{{%= {0} %}}", oProperty.Name.ToJSProper()) : oProperty.GetValue(@object, null).IsNotNull(String.Empty, (X) => X.ToString());
        }
    }
}
